package com.zhangwei.touch.vpi;

import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;

import com.viewpagerindicator.TabPageIndicator;
import com.zhangwei.touch.R;
import com.zhangwei.touch.fragment.ImageFragment_;
import com.zhangwei.touch.vpi.adapter.VpiPageAdapter;

import org.androidannotations.annotations.AfterInject;
import org.androidannotations.annotations.AfterViews;
import org.androidannotations.annotations.EActivity;
import org.androidannotations.annotations.ViewById;

import java.util.ArrayList;

@EActivity(R.layout.activity_vp)
public class VpActivity extends AppCompatActivity {

    @ViewById
    TabPageIndicator tpi;
    @ViewById
    ViewPager vp;
    private String[] titles = {"测试1", "测试2", "测试3", "测试4"};


     //View 初始化之前
    @AfterInject
    public void inject() {
        Log.e("inject", "inject");
    }

    //View 初始化之后
    @AfterViews
    public void initView() {
        ArrayList<Fragment> fragments = new ArrayList<>();
        fragments.add(new ImageFragment_());
        fragments.add(new ImageFragment_());
        fragments.add(new ImageFragment_());
        fragments.add(new ImageFragment_());
        VpiPageAdapter adapter = new VpiPageAdapter(fragments, getSupportFragmentManager(), titles);
        vp.setAdapter(adapter);
        tpi.setViewPager(vp);

    }


}
